﻿using System.Windows.Automation;

namespace QuickUIT.Controls
{
    /// <summary>
    /// Represents a hyperlink control. 
    /// </summary>
    public class UIHyperlink : UIBaseControl
    {
        /// <summary>
        /// Gets a value which indicates whether the value of a control is read-only. 
        /// </summary>
        public new bool IsReadOnly
        {
            get { return base.IsReadOnly; }
        }

        /// <summary>
        /// Gets the current value of the hyperlink. 
        /// </summary>
        public new string Value
        {
            get { return base.Value; }
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="UIHyperlink"/> class. 
        /// </summary>
        public UIHyperlink() : base(ControlType.Hyperlink)
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="UIHyperlink"/> class.
        /// </summary>
        /// <param name="parent">The parent of this control.</param>
        public UIHyperlink(UIBaseControl parent)
            : base(parent, ControlType.Hyperlink)
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="UIHyperlink"/> class.
        /// </summary>
        /// <param name="locator">The locator used to find the specific control.</param>
        public UIHyperlink(string locator)
            : base(null, ControlType.Hyperlink, locator)
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="UIHyperlink"/> class.
        /// </summary>
        /// <param name="parent">The parent of this control.</param>
        /// <param name="locator">The locator used to find the specific control.</param>
        public UIHyperlink(UIBaseControl parent, string locator)
            : base(parent, ControlType.Hyperlink, locator)
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="UIHyperlink"/> class.
        /// </summary>
        /// <param name="control">The underlying <see cref="AutomationElement"/> of the control.</param>
        public UIHyperlink(AutomationElement control) : base(control, ControlType.Hyperlink)
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="UIHyperlink"/> class.
        /// </summary>
        /// <param name="parent">The parent of the control</param>
        /// <param name="control">The underlying <see cref="AutomationElement"/> of the control.</param>
        public UIHyperlink(UIBaseControl parent, AutomationElement control) : base(parent, control, ControlType.Hyperlink)
        {
        }

        /// <summary>
        /// Opens the hyperlink. 
        /// </summary>
        public void Open()
        {
            Invoke();
        }
    }
}
